package main

import (
	"fmt"
	"io/ioutil"
	"net/http"
	"strings"
)

func main() {
	apiUrl := "http://192.168.3.21:8005/req/post"
	//	设置请求头，body 体
	contentType := "application/json" // post 固定
	data := `{"name":"posttest"}`
	// string 需要转换为reader类型
	resp, _ := http.Post(apiUrl, contentType, strings.NewReader(data))
	b, _ := ioutil.ReadAll(resp.Body)
	fmt.Println("获取到的响应数据：", string(b))
}
